package com.ruoyi.common.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class PackageEntity {


    private int id;

    private String uuid;

    private String title;

    private String subTitle;

    private int tokens;

    private int chatCount;

    private int advancedChatCount;

    private int drawCount;

    private int days;

    private int state;

    private int calcTypeId;

    private CalcType calcType;

    private BigDecimal price;

    private long top; // 是否置顶，0表示不置顶，否则表示置顶时间，越后面置顶的，越靠前

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date updateTime;


    public static final int STATE_DRAFT = 0;// 草稿
    public static final int STATE_ON_SALES = 10; // 上架(上架后不允许修改)
    public static final int STATE_OFF_SHELVES = 20; // 下架（下架后允许修改后再次上架）
    public static final int STATE_DELETED = 30; // 已删除（仅无购买的情况下支持删除）

    public enum CalcType {
        Total(1),
        Daily(2),
        Hourly(3),
        ThreeHourly(4);

        private final int code;

        CalcType(int code) {
            this.code = code;
        }

        public int getCode() {
            return code;
        }
    }


    public static CalcType getCalcType(int code) {
        for (CalcType type : CalcType.values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }
}
